package com.tz.aop.test.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class MyAdvice {
    private final String pintCut = "execution(* *..*.*ServiceImpl.*(..))";

    @Before(value = "fn()")
    public void beforeTest(JoinPoint joinPoint) {
        Object aThis = joinPoint.getThis();
        Object target = joinPoint.getTarget();
        System.out.println("注解方式前置通知:aThis = " + aThis + "---target = " + target);
    }

    @After(pintCut)
    public void afterTest() {
        System.out.println("这是注解方式的最终通知");
    }

    @Around(pintCut)
    public void aroundTest(ProceedingJoinPoint pjp) throws Throwable {
        Object proceed = pjp.proceed();
        System.out.println("环绕通知：" + proceed);
    }



    @Pointcut("execution(* *..*.*ServiceImpl.*(..))")
    public void fn() {}

}
